package cc.linker.steplink.crm.merchant.common;

import cc.linker.steplink.crm.commons.coupon.CouponCustomerInfo;
import cc.linker.steplink.crm.commons.model.PcUserInfo;
import cc.linker.steplink.crm.merchanth5.commons.UserInfoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: CKQ
 * @DateTime: 2020/8/19 9:14
 * @Description: TODO
 */
@Component
public class PcCouponCustomer {
    @Autowired
    private UserInfoUtil userInfoUtil;
    /**
     * @Description：组装优惠券用户信息
     * @DateTime：2020/8/18 14:45
     * @Params：
     * @Return：
     */
    public CouponCustomerInfo getCouponCustomerInfo(HttpServletRequest request) {
        PcUserInfo userinfo = this.userInfoUtil.getPcUserInfo(request);
        CouponCustomerInfo customerInfo = CouponCustomerInfo
                .builder()
                .customerId(userinfo.getSaler() ? userinfo.getCustomerId() : userinfo.getOrgId())
                .customerName(userinfo.getAdminName())
                .customerPhone(userinfo.getSaler() ? userinfo.getBindPhone() : "")
                .cover("")
                .orgId(userinfo.getOrgId())
                .build();
        return customerInfo;
    }
}
